package edu.asu.sefcom.extract.profile;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.log4j.Logger;
import org.jsoup.Jsoup;


public class ProfileCommunityParser1 extends MultiFieldParser {

	Logger logger = Logger.getLogger(ProfileCommunityParser1.class);

	@Override
	public List<String> extractFields(String post) {
		String start = "Member of:";
		String stop = "Account type";

		String targetStr = StringUtil.returnNormalPost(
				start, stop, post, 0);

		String regex = "<a href=\".*rel=\"group\">.*</a>";
		Pattern p = Pattern.compile(regex);
		Matcher m = p.matcher(targetStr);
		List<String> communities = new ArrayList<String>();
		int counter=0;
		String txt ="";
		if (m.find()) {
			 txt = m.group(counter++);
			txt = Jsoup.parse(txt).text();
		}
		communities = Arrays.asList(txt.split(","));
		logger.warn(communities);
		return communities;
	}
}
